package com.jiapu.controller;

import com.jiapu.common.Result;
import com.jiapu.entity.Relationship;
import com.jiapu.mapper.RelationshipMapper;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

@RestController

@RequestMapping("/rela")
public class RelationshipController {

    @Resource
    RelationshipMapper relationshipMapper;

    @GetMapping
    public Result getRelationship(){

        List<Relationship> relationshipList = relationshipMapper.findAllr();
        return Result.success(relationshipList);
    }

    @PostMapping
    public String addRelationship(@RequestBody Relationship relationship){
        relationshipMapper.saver(relationship);
        return "success";
    }

    @PutMapping
    public String updateRelationship(@RequestBody Relationship relationship){
        relationshipMapper.updateByIdr(relationship);
        return "success";
    }


    @PutMapping("/del")
    public String deleteRelationship(@RequestBody Relationship relationship){
        relationshipMapper.deleteByIdr(relationship);
        return "success";
    }
}
